package cn.tianya.irock.data.model;

import java.util.Hashtable;

public class SiteSettings {
	private Hashtable<String, Object> settings = new Hashtable<String, Object>();
	
	private int siteSettingsId = 1;
	private int defaultRoleCookieExpiration = 20;
	private int defaultImageThumbWidth = 320;
	private int defaultImageThumbHeight = 240;
	
	private boolean disabled = false;
	private boolean defaultEnableRoleCookie = true;
	private boolean defaultEnableAttachments = true;
	
	//private Site site = null;
	
	private String name;
	private String defaultRoleCookieName = ".IROCKROLES";
	private String defaultAllowedAttachmentTypes = "zip;rar;jpg;gif;png;wma;mp3;txt;swf;flv;css";
	private String defaultMaskImage = "mask.png";

	private long defaultMaxAttachmentSize = 1024; // in Kilobytes

	public Hashtable<String, Object> getSettings() {
		return settings;
	}

	public void setSettings(Hashtable<String, Object> value) {
		settings = value;
	}
	
	public void setName(String value) {
		this.name = value;
	}
	
	public String getName() {
		return this.name;
	}

	public String getRoleCookieName() {
		String v = (String) settings.get("RoleCookieName");

		if (v != null)
			return v;
		else
			return defaultRoleCookieName;
	}
	
	public String getMaskImage() {
		String v = (String) settings.get("MaskImage");

		if (v != null)
			return v;
		else
			return defaultMaskImage;
	}
	

	public void setRoleCookieName(String value) {
		settings.put("RoleCookieName", value);
	}
	
	public String getAllowedAttachmentTypes() {
		String v = (String) settings.get("AllowedAttachmentTypes");

		if (v != null)
			return v;
		else
			return defaultAllowedAttachmentTypes;
	}
	
	public void setAllowedAttachmentTypes(String value) {
		settings.put("AllowedAttachmentTypes", value);
	}

	public int getRoleCookieExpiration() {
		Object v = settings.get("RoleCookieExpiration");

		if (v != null)
			return (Integer) v;
		else
			return defaultRoleCookieExpiration;
	}
	
	public int getImageThumbWidth() {
		Object v = settings.get("ImageThumbWidth");

		if (v != null)
			return (Integer) v;
		else
			return defaultImageThumbWidth;
	}
	
	public int getImageThumbHeight() {
		Object v = settings.get("ImageThumbHeight");

		if (v != null)
			return (Integer) v;
		else
			return defaultImageThumbHeight;
	}

	public void setRoleCookieExpiration(int value) {
		settings.put("RoleCookieExpiration", value);
	}

	public boolean enableRoleCookie() {
		Object v = settings.get("EnableRoleCookie");

		if (v != null)
			return (Boolean)v;
		else
			return defaultEnableRoleCookie;
	}
	
	public void setEnableRoleCookie(boolean value) {
		settings.put("EnableRoleCookie", value);
	}
	
	public boolean enableAttachments() {
		Object v = settings.get("EnableAttachments");

		if (v != null)
			return (Boolean)v;
		else
			return defaultEnableAttachments;
	}
	
	public void enableAttachments(boolean value) {
		settings.put("EnableAttachments", value);
	}
	
	public long getMaxAttachmentSize() {
		Object v = settings.get("MaxAttachmentSize");
		
		if (v != null)
			return (Long)v;
		else
			return defaultMaxAttachmentSize;
	}
	
	public void setMaxAttachmentSize(long value) {
		settings.put("MaxAttachmentSize", value);
	}

	public int getSiteSettingsId() {
		return siteSettingsId;
	}

	public void setSiteSettingsId(int value) {
		siteSettingsId = value;
	}

	public boolean isDisabled() {
		return disabled;
	}

	public void setDisabled(boolean disabled) {
		this.disabled = disabled;
	}

	//public Site getSite() {
	//	return site;
	//}

	//public void setSite(Site site) {
	//	this.site = site;
	//}
}
